package ccnu.agile.service.impl;

import ccnu.agile.mapper.EnvironmentCheckMapper;
import ccnu.agile.service.IEnvironmentCheckService;
import ccnu.agile.utils.LogUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 环境检查服务类
 * @Author: JreamY
 * @Date: 2021/10/22
 **/
@Service("environmentCheckService")
public class EnvironmentCheckServiceImpl implements IEnvironmentCheckService {

    @Autowired
    private EnvironmentCheckMapper environmentCheckMapper;

    @Override
    public void healthCheck() {

        // datasource check
        LogUtils.info(this, "datasource check start");
        try {
            environmentCheckMapper.dual();
        } catch (Exception e) {
            LogUtils.error("datasource check fail: ", e.getStackTrace());
            System.exit(-1);
        }
        LogUtils.info(this, "datasource check success");

    }
}
